//
//  CustomerView.swift
//  Intrinsic Content Size
//
//  Created by NMXY on 2020/12/30.
//

import UIKit

class CustomerView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.orange
        self.translatesAutoresizingMaskIntoConstraints = false
        self.addSubview(label)
        
        NSLayoutConstraint.activate([
            label.leftAnchor.constraint(equalTo: self.leftAnchor),
            label.rightAnchor.constraint(equalTo: self.rightAnchor),
            label.topAnchor.constraint(equalTo: self.topAnchor),
            
            self.widthAnchor.constraint(equalToConstant: 200),
            self.bottomAnchor.constraint(equalTo: label.bottomAnchor),
            
        ])
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private lazy var label: UILabel = {
        let tempLabel = UILabel()
        tempLabel.text = "No Intrinsic Content Size,是通过先把 width 和 bottom 写在 init 方法里面"
        tempLabel.translatesAutoresizingMaskIntoConstraints = false
        tempLabel.numberOfLines = 0
        return tempLabel
    }()

}
